﻿@using HardHatCore.ApiModels.Plugin_Interfaces;
@using HardHatCore.ApiModels.Plugin_BaseClasses
@using HardHatCore.HardHatC2Client.Pages
@using HardHatCore.HardHatC2Client.Plugin_BaseClasses

<MudCardContent Style="background:#111111; color:white;">
    @if (currentTasks is not null)
    {
        @foreach (var currenttask in currentTasks)
        {
            ExtImplantTaskResult_Base? taskResult = null;
            @if (ImplantInteract.TaskResultDic.TryGetValue(currenttask, out var _taskresult))
            {
                taskResult = _taskresult;
            }
            <InteractWindowContent @ref="@ImplantInteract.TaskPanels[currenttask.Id]" currenttask="@currenttask" commandHeaderText="@currenttask.TaskHeader" implant="@implant" CardContent="@taskResult"></InteractWindowContent>
        }

    }
</MudCardContent>

@code {
    [Parameter]
    public List<ExtImplantTask_Base>? currentTasks { get; set; } = new List<ExtImplantTask_Base>();

    [Parameter]
    public ExtImplant_Base implant { get; set; }

    private bool isInitialized { get; set; } = false;

    public async Task ForceListUpdate(List<ExtImplantTask_Base> newCurrentTasks)
    {
        currentTasks = newCurrentTasks;
        if (isInitialized)
        {
            await InvokeAsync(StateHasChanged);
        }
    }

    protected override void OnInitialized()
    {
       isInitialized = true;
    }
}
